#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <unordered_map>
// 乘积最大子数组：https://leetcode.cn/problems/maximum-length-of-subarray-with-positive-product/
using namespace std;
class Solution {
public:
    int getMaxLen(vector<int>& nums) {
        int n=nums.size();
        int ret=0;
        vector<int> f(n+1),g(n+1);
        f[0]=g[0]=0;
        for(int i=1;i<=n;i++)
        {
            if(nums[i-1]>0)
            {
                f[i]=f[i-1]+1;
                g[i]=g[i-1]==0?0:g[i-1]+1;
            }
            else if(nums[i-1]<0)
            {
                f[i]=g[i-1]==0?0:g[i-1]+1;
                g[i]=f[i-1]+1;
            }
            else
                f[i]=g[i]=0;
            ret=max(ret,f[i]);
        }
        return ret;
    }
};